<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="base::head(~{})">
</head>
<body class="login-bg">
	<div class="login layui-anim layui-anim-up">
		<div class="message">后台管理系统</div>
		<div id="darkbannerwrap"></div>

		<form method="post" class="layui-form">
			<input name="userName" placeholder="用户名" type="text" lay-verify="required" class="layui-input">
			<hr class="hr15">
			<input name="password" placeholder="密码" type="password" lay-verify="required" class="layui-input">
			<hr class="hr15">
			<input value="登录" lay-submit lay-filter="login" style="width: 100%;" type="submit">
			<hr class="hr20">
		</form>
	</div>

	<script>
		$(function() {
			layui.use('form', function() {
				var form = layui.form;
				// layer.msg('玩命卖萌中', function(){
				//   //关闭后的操作
				//   });
				//监听提交
				form.on('submit(login)', function(data) {
					var param = data.field;
					$.ajax({
						type : 'post',//方法类型
						dataType : 'json',//预期服务器返回的数据类型
						url : ctxPath + '/login',//url
						data : param,
						success : function(result) {
							console.log(result);
							if (result.code == 0) {
								window.location.href = "./index";
								return;
							} else {
								layer.msg(result.msg, {icon : 2});
							}
						},
						error : function() {
							layer.msg('用户名或密码错误' + result.msg, {icon : 2});
						}
					});
					return false;
				});
			});
		})
	</script>
</body>
</html>